<script>
  import $ from 'dfish-widget'
  import Method from '../Method.vue'

  export default {
    mixins: [Method],
    data() {
      return {
        name: '$.config(settings)',
        remark: '设置全局默认配置。',
        attrs: [{
          name: 'settings',
          remark: '配置参数',
          type: 'Object',
          attrs: [{
            name: 'autoPlaceholder',
            remark: '如果设为true，表单将自动填充placeholder',
            type: 'Boolean',
          }, {
            name: 'cnBytes',
            remark: '一个汉字算几个字节。默认值为2',
            type: 'Number',
          }, {
            name: 'defaultOptions',
            remark: '每个 widget 类都可以定义默认样式，以 widget type 作为 key',
            type: 'Object',
          }, {
            name: 'downloadTarget',
            remark: '调用$.download方法时，指定下载的目标窗口。可选值: <var>_blank</var><var>_self</var><var>_parent</var><var>_top</var>',
            type: 'String',
          }, {
            name: 'http',
            remark: '与服务器数据交互的配置项。请参考 <a href=http://www.axios-js.com/zh-cn/docs/#axios-get-url-config-1 target=_blank>Axios配置</a>',
            type: 'Object',
          }, {
            name: 'templateDir',
            remark: '模板目录。调用Dialog命令时template参数会基于这个值',
            type: 'String',
          }, {
            name: 'wifiConfirm',
            remark: '非wifi网络环境下的上传下载是否提示',
            type: 'Boolean',
          }, ]
        }],
        examples: [{
          remark: '设置一些配置项',
          code: `
            $.config({
              autoPlaceholer: true,
              templateDir: 'views/',
              downloadTarget: '_blank',
              cnBytes: 3,
              http: {
                baseURL: 'http://127.0.0.1/data/',
                headers: {
                  post: {
                    'Content-Type': 'application/x-www-form-urlencoded'
                  },
                  'x-requested-with': 'dfish'
                }
                withCredentials: true
              },
              defaultOptions: {
                'w-label': {
                  width: 120
                }
              }
            })
            `
        }]
      }
    }
  }
</script>
